<template>
  <el-config-provider :locale="zhCn">
    <div class="app-container">
      <el-container>
        <!-- 顶部导航栏 -->
        <el-header class="app-header">
          <div class="header-container">
            <div class="logo">
              <img src="./assets/logo.png" alt="Logo" class="logo-image" />
              <span class="logo-text">AI 写作助手</span>
            </div>
            <div class="nav-menu">
              <router-link to="/articles" class="nav-item">文章管理</router-link>
              <router-link to="/articles/new" class="nav-item">创建文章</router-link>
              <router-link to="/prompt-templates" class="nav-item">提示词模板</router-link>
              <router-link to="/ai-models" class="nav-item">AI 模型设置</router-link>
            </div>
            <div class="user-menu">
              <el-dropdown>
                <span class="user-dropdown-link">
                  用户名 <el-icon><arrow-down /></el-icon>
                </span>
                <template #dropdown>
                  <el-dropdown-menu>
                    <el-dropdown-item>个人设置</el-dropdown-item>
                    <el-dropdown-item>退出登录</el-dropdown-item>
                  </el-dropdown-menu>
                </template>
              </el-dropdown>
            </div>
          </div>
        </el-header>
        
        <!-- 主要内容区域 -->
        <el-main class="app-main">
          <router-view />
        </el-main>
        
        <!-- 页脚 -->
        <el-footer class="app-footer">
          <p>© 2023 AI 写作助手 - 版权所有</p>
        </el-footer>
      </el-container>
    </div>
  </el-config-provider>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useRoute } from 'vue-router'
import { ArrowDown } from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'

const route = useRoute()

// 计算当前激活的菜单项
const activeMenu = computed(() => {
  // 如果是编辑文章页面，激活文章管理菜单
  if (route.path.includes('/articles/') && route.path.includes('/edit')) {
    return '/articles'
  }
  // 如果是新建文章页面，激活创建文章菜单
  if (route.path === '/articles/new') {
    return '/articles/new'
  }
  return route.path
})
</script>

<style>
/* 全局样式 */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
}

#app {
  height: 100%;
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 头部样式 */
.app-header {
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px !important;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
}

.logo-image {
  height: 32px;
  margin-right: 10px;
}

.logo-text {
  font-size: 18px;
  font-weight: bold;
  color: #409EFF;
}

.nav-menu {
  display: flex;
  gap: 20px;
}

.nav-item {
  color: #606266;
  text-decoration: none;
  font-size: 16px;
  transition: color 0.3s;
}

.nav-item:hover, .nav-item.router-link-active {
  color: #409EFF;
}

.user-menu {
  display: flex;
  align-items: center;
}

.user-dropdown-link {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #606266;
}

/* 主内容区域样式 */
.app-main {
  padding: 0;
  background-color: #f5f7fa;
  flex: 1;
  overflow: auto;
}

/* 页脚样式 */
.app-footer {
  background-color: #fff;
  text-align: center;
  color: #909399;
  font-size: 14px;
  padding: 20px 0;
  border-top: 1px solid #e4e7ed;
}
</style> 